package com.shardings.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shardings.entity.UserDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: LCG
 * @date: 2022-11-09 16:09:20
 * @description:
 **/
@Repository
@Mapper
public interface TestUserDao extends BaseMapper<UserDTO>{

    @Insert("insert into m_user(userName,loginName,buMen,path,sex,createTime,price) values(#{userName},#{loginName},#{buMen},#{path},#{sex},#{createTime},#{price})")
    int addOne(UserDTO userDTO);

    @Select("select * from m_user where userName like concat('%',#{userName},'%')")
    List<UserDTO> getUserList(@Param("userName") String userName);


    @Select("select * from m_user where buMen in (#{buMen}) and id > #{userName}")
    List<UserDTO> getUserList2(@Param("userName") String userName,@Param("buMen") String buMen);

    //按照多字段分不分表
    @Select("select * from m_user where buMen = (#{buMen}) and userName=#{userName} and id >= #{id} ")
    List<UserDTO> getUserList3(@Param("userName") String userName,@Param("buMen") String buMen,@Param("id") Long id);

    int insertList(List<UserDTO> userDTOList);

}
